'use strict';
const dayjs = require("dayjs");
const {getDefaultModelConfig} = require("../../utils/common");

module.exports = app => {
    const { STRING, INTEGER, DATE, TINYINT, TEXT } = app.Sequelize;
    return app.model.define(
        'ProductSpec',
        {
            id: {type: INTEGER, primaryKey: true, autoIncrement: true},
            product_id: {type: INTEGER, allowNull: false, comment: '商品ID'},
            spec_name: {type: STRING(100), allowNull: false, comment: '规格名称，如：颜色、尺寸'},
            spec_values: {type: TEXT, comment: '规格值，JSON格式存储，如：["红色","蓝色","绿色"]'},
            sort: {type: INTEGER, defaultValue: 0, comment: '排序'},
            status: {type: TINYINT, defaultValue: 1, comment: '状态：1-启用，0-禁用'},
            ...getDefaultModelConfig(app)
        },
        {
            tableName: 'product_spec',
            timestamps: true,
            createdAt: 'create_time',
            updatedAt: 'update_time'
        }
    );
}; 